<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>6.7课堂练习柱形图</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.3.2/echarts.min.js"></script>
</head>
<body>
    <div style="width: 600px;height:400px;"></div>
    <script>
        //1.echarts.js
        //2.准备一个具备大小的dom
        //3.初始化echarts实例
        //4.设置option
        var myChart = echarts.init(document.querySelector('div'));
        var option = {
            xAxis:{
                name:'姓名',
                type:'value',
            },
            yAxis:{
                type:'category',
                data:['张三','李四','王五','闰土','小明','茅台','二妞','大强'],
                
            },
            series:[
               {
                    name:'成绩',
                    type:'bar',
                    data:[88,92,63,77,94,80,72,86],
                    barWidth: '50%', // 设置柱子宽度为类目宽度的50%
                    markPoint:{
                       data:[
                        {
                            type:'max',
                            name:'最大值',
                        },
                        {
                            type:'min',
                            name:'最小值',
                        },
                       ],
                    },
                    markLine:{
                        data:[
                            {
                                type:"average",
                                name:"平均值",
                                color:"#baf"
                            }
                        ]
                    },
                    label:{
                        show:true,
                        rotate: 20,   //旋转角度
                        position: 'inside' //显示位置
                    },
                    itemStyle: {
                        // 设置柱状图的颜色
                        color: 'green'
                    }
               }
            ]   
        }
        myChart.setOption(option);
    </script>
</body>
</html>